package cn.harry.modular.ai.service.impl;

import cn.harry.common.exception.ApiException;
import cn.harry.modular.ai.enums.ErrorCodeConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.harry.modular.ai.mapper.ChatConversationMapper;
import cn.harry.modular.ai.service.ChatConversationService;
import cn.harry.modular.ai.domain.ChatConversation;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;

/**
 * AI 聊天对话服务实现类
 *
 * @author harry
 * @公众号 Harry技术
 */
@Service
@RequiredArgsConstructor
public class ChatConversationServiceImpl extends ServiceImpl<ChatConversationMapper, ChatConversation> implements ChatConversationService {

    @Override
    public ChatConversation validateChatConversationExists(Long conversationId) {
        ChatConversation conversation = getById(conversationId);
        if (conversation == null) {
            throw new ApiException(ErrorCodeConstants.CHAT_CONVERSATION_NOT_EXISTS);
        }
        return conversation;
    }
}
